/*
 * @Author: silence
 * @Date: 2022-04-06 17:36:58
 * @LastEditTime: 2022-04-25 11:04:50
 * @LastEditors: devdeMBP.lan
 * @Description: In User Settings Edit
 * @FilePath: /flutter_template_app/lib/widgets/MyTimeUtils.dart
 */

class MyTimeUtils {
  /**
   * 年/月/日 时:分
   * stamp 秒
   */
  static String timeStampToTimeString(int stamp) {
    DateTime date = DateTime.fromMillisecondsSinceEpoch(stamp * 1000);
    return "${value(date.year)}/${value(date.month)}/${value(date.day)} ${value(date.hour)}:${value(date.minute)}";
  }

    /**
   * 年-月-日
   * stamp 秒
   */
  static String timeStampToTimeString_YMD(int stamp) {
    DateTime date = DateTime.fromMillisecondsSinceEpoch(stamp * 1000);
    return "${value(date.year)}-${value(date.month)}-${value(date.day)}";
  }



  /**
   * 月-日
   * stamp 秒
   */
  static String timeStampToTimeString_1(int stamp) {
    DateTime date = DateTime.fromMillisecondsSinceEpoch(stamp * 1000);
    return "${date.month}-${date.day}";
  }

  /**
   * 当前时间戳
   */
  static int currentTimeMillis() {
    return new DateTime.now().millisecondsSinceEpoch;
  }

  /**
   * 格式化
   */
  static String value(int num) {
    if (num < 10) {
      return "0${num}";
    }

    return "${num}";
  }
}
